port=5555
echo "flower服务绑定的端口：${port}"
if [ $# != 0 ]
then
    if [ $1 == "start" ]
    then
        nohup flower -A django_celery_tasks --address=0.0.0.0 --port=$port --auto_refresh=False --basic_auth=admin:123 > ./logs/flower.log 2>&1 & 
        echo "flower服务启动成功..."
    elif [ $1 == 'stop' ]
    then
        flower_pid=`lsof -i:5555 | grep -v PID | awk '{print $2}'` && if [ "$flower_pid" ];then kill -9 $flower_pid;fi
        echo "flower服务停止成功..."
    else
        echo "start：开启(or 重启)服务；stop：停止服务；help：帮助信息"
    fi
else
    echo "参数错误，可以尝试命令：bash celery-master.sh help"
fi